package daybook.io.args;

import com.beust.jcommander.Parameters;
import com.beust.jcommander.ParametersDelegate;
import daybook.io.formatter.Format;

import java.time.LocalDate;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

import static daybook.Resources.RESOURCES_NAME;
import static daybook.Resources.Usages.COMMAND_PRINT;

@Parameters(separators = "=", resourceBundle = RESOURCES_NAME,
        commandDescriptionKey = COMMAND_PRINT)
public class CommandPrint {
    @ParametersDelegate
    private final TransactionArgs transactionArgs;

    @ParametersDelegate
    private final FormatArgs formatArgs;

    public CommandPrint(TransactionArgs transactionArgs, FormatArgs formatArgs) {
        this.transactionArgs = Objects.requireNonNull(transactionArgs);
        this.formatArgs = Objects.requireNonNull(formatArgs);
    }

    public boolean isNegative() {
        return transactionArgs.isNegative();
    }

    public Optional<List<String>> getAccounts() {
        return transactionArgs.getAccounts();
    }

    public LocalDate getStartDate() {
        return transactionArgs.getStartDate();
    }

    public LocalDate getEndDate() {
        return transactionArgs.getEndDate();
    }

    public Format getFormat() {
        return formatArgs.getFormatWithDefault();
    }

    @Override
    public String toString() {
        return "CommandPrint{" +
                "transactionArgs=" + transactionArgs +
                ", formatArgs=" + formatArgs +
                '}';
    }
}
